import {_TOTAL_PATH_} from '../../js/my-core'

export const getHotList = (_this, val) => {
  const url = ['/api/anime/hot_list/30', '/api/manga/hot_list/30', '/api/novel/hot_list/30']
  _this.$axios({
    method: 'get',
    url: url[val]
  })
    .then((res) => {
      if (res.data.code === 200) {
        _this.itemList = []
        let i = 0
        for (let item of res.data.data) {
          let rank = {id: i, no: i + 1, name: 'NULL', href: '#', hot: 0}
          rank.name = item.name
          rank.href = _TOTAL_PATH_[val] + item.id
          rank.hot = item.hot
          _this.itemList.push(rank)
          i++
        }
        console.log(res.data.data)
      } else {
        console.log(res.data.msg)
      }
    })
    .catch((error) => {
      console.log(error)
    })
}
